package com.hzy.admin.controller.system;

import com.hzy.admin.framework.ApiResult;
import com.hzy.admin.framework.controller.BaseController;
import com.hzy.admin.models.vo.system.AuthUserVo;
import com.hzy.admin.services.system.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 登陆 授权
 *
 * @author HZY
 */
@Api(tags = "登陆 授权")
@RequestMapping("/admin/login")
@RestController
public class LoginController extends BaseController {
    private final ISysUserService sysUserService;

    public LoginController(ISysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    /**
     * 检查账户
     *
     * @param authUserDto
     * @return
     */
    @ApiOperation("检查账户")
    @PostMapping("/check")
    @ResponseBody
    public ApiResult<?> check(@RequestBody AuthUserVo authUserDto) {
        String token = this.sysUserService.check(authUserDto);
        Map<String, Object> map = new HashMap<>();
        map.put("token", token);
        return this.resultOk(map);
    }

}
